from xml.dom.ext.reader import HtmlLib
from urlparse import urlparse

class Document():
	def __init__(self, URL, HTML, referrer):
		# Parse the HTML using pyxml
		reader      = HtmlLib.Reader()
		#self.all    = reader.fromString(HTML)
	
		self.anchors = []
		self.forms   = []
		self.images  = []
		self.links   = []
		
		# Get the domain
		url_data = urlparse(URL)
		
		self.cookie       = ""
		self.domain	 	  = url_data.netloc
		# Last modified date. Ideally this is taken from the header information
		self.lastModified = ""
		self.readyState   = "complete"
		self.referrer	  = referrer
		self.title		  = ""
		self.URL		  = URL
		
	# For parsing the anchors
	# For parsing the links
	# For parsing the images
	# For parsing the forms
		
	def close(self):
		print "\t\t--> Website attempted to close output stream"
	
	def getElementById(self, element_id):
		pass
	
	def getElementsByName(self, element_name):
		pass
	
	def open(self):
		print "\t\t--> Website attempted to open output stream"
	
	def write(self, msg):
		print "\t\t--> Website attempted write: " + msg
	
	def writeln(self, msg):
		print "\t\t--> Website attempted writeln: " + msg
		
	def createElement(self, type):
		pass
